package fr.insta.reverse.uml.service;

public class ServiceFactory
{
	@SuppressWarnings("rawtypes")
	public static IService getService(ServiceName serv)
	{
		try
		{
			Class<?> clazz = Class.forName("fr.insta.reverse.uml.service.Service" + serv.getNom());
			IService service = (IService) clazz.newInstance();

			if (service == null)
				throw new ClassNotFoundException();

			return service;
		}
		catch (ClassNotFoundException | InstantiationException | IllegalAccessException e)
		{
			System.out.println("SERVICE NOT FOUND : " + serv.getNom());
			return null;
		}
	}
}